unit uSelectExp;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinBlueprint,
  dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom, dxSkinDarkSide,
  dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
  dxSkinXmas2008Blue, Vcl.StdCtrls, cxContainer, cxEdit, cxCheckListBox,
  Vcl.Menus, Vcl.ActnList, cxButtons,StrMap;

type
  TFrmSelectExp = class(TForm)
    ckbExpress: TcxCheckListBox;
    GroupBox1: TGroupBox;
    ActionList1: TActionList;
    cxButton13: TcxButton;
    cxButton14: TcxButton;
    actOK: TAction;
    actCancel: TAction;
    procedure actCancelExecute(Sender: TObject);
    procedure actOKExecute(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    expMap:TStrMap;
    outStr:string;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmSelectExp: TFrmSelectExp;
  function fSetExpress(inStr:string):string;

implementation

{$R *.dfm}

uses uDm, Console, ucommFunction;

function fSetExpress(inStr:string):string;
var
  cItem: TcxCheckListBoxItem;
begin
  Application.CreateForm(TFrmSelectExp,FrmSelectExp);
  with FrmSelectExp do
  begin
    expMap:=TStrMap.Create;
    dm.crsExpress.First;
    while not Dm.crsExpress.Eof do
    begin
      expMap.Put(dm.crsExpress.FieldByName('PARAMCAP').AsString,dm.crsExpress.FieldByName('DVALUE').AsString);
      cItem:=ckbExpress.Items.Add;
      cItem.Text:=dm.crsExpress.FieldByName('PARAMCAP').AsString;
      if Pos(dm.crsExpress.FieldByName('DVALUE').AsString,inStr)>0 then
        cItem.Checked:=True
      else
        cItem.Checked:=False;
      dm.crsExpress.Next;
    end;
    ShowModal;
    Result:=outStr;
    expMap.Free;
    FreeAndNil(FrmSelectExp);
  end;
end;

procedure TFrmSelectExp.actCancelExecute(Sender: TObject);
begin
  Self.ModalResult:=mrCancel;
end;

procedure TFrmSelectExp.actOKExecute(Sender: TObject);
var
  i:Integer;
begin
  outStr:='';
  for I := 0 to ckbExpress.Items.Count - 1 do
  begin
    if ckbExpress.Items[I].Checked then
    begin
      if outStr <> '' then
        outStr := outStr + '|';
      outStr := outStr + expMap.Get(ckbExpress.Items[I].Text);
    end;
  end;

end;

procedure TFrmSelectExp.FormCreate(Sender: TObject);
begin
  pSetCaption(Self);
end;

end.
